<%@ include file="/WEB-INF/jsp/include/head.jsp" %><%@ page language="java" pageEncoding="UTF-8"%><%@ taglib uri="http://geeksaga.com/pagination-taglib" prefix="bbs" %>
<html>
<head>
    <%@ include file="/WEB-INF/jsp/include/title.jsp" %>
    <%@ include file="/WEB-INF/jsp/include/common_css.jsp" %>
    <link rel="stylesheet" type="text/css" media="screen" href="<c:url value="/css/skin/default/default.css"/>"/>
    <%@ include file="/WEB-INF/jsp/include/common_script.jsp" %>    
    <script type="text/javascript">
    //<![CDATA[
    function serverMessage() {
        if("${serverMessage}" != "") {
            alert("${serverMessage}");
        }
    }

    function checkedAll() {
        if($("#checkedSid").attr("checked")) {
            $("input:checkbox:not(checked)").attr("checked", "checked");
        } else {
            $("input:checkbox:checked").attr("checked", "");
        }
    }

    function category() {
    	$("#categorySid").before("<img id='empty' src='<c:url value='/img/skin/${bbsType.bbsSkin}/empty.gif'/>' width='120' height='0' />");
        $("#categorySid").hide();

        var txt = "<table width='120'cellspacing='0' cellpadding='0' style='position:absolute; height:21px; cursor:default;'>" +
                  "<tr height='1'><td><\/td><\/tr>" +
                  "<tr><td>"+
                  "<table cellspacing='0' cellpadding='0' style='line-height:117%; width:100%; height: 19px; border:1px solid #c0c0c0;font-family:vernada;font-size:9pt;'>" + 
                  "<tr onclick=\"showLayer('categoryLayer','categoryMain')\">" +
                  "<td id='categoryMain'>&nbsp;" + $("#categorySid option:selected").text() + "<\/td>" +
                  "<td align='right' width='10' bgcolor='#eeeeee'><img src=\"<c:url value='/img/skin/${bbsType.bbsSkin}/dot.gif'/>\" style='vertical-align:middle;' />" +
                  "<\/td><\/tr>" +
                  "<\/table>" +
                  "<table id='categoryLayer' style='display: none; width:100%; border: 1px solid #c0c0c0;font-family:vernada;font-size:9pt;background-color:#ffffff;'>";

        $("#categorySid option").each(function () {
            txt += "<tr height='18' onclick='change(this, \"" + $(this).val() + "\");'\"><td width='120' onmouseover='over(this)' onmouseout='out(this)' style=";
            if ($("#categorySid option:selected").text() == $(this).text()) {
                txt += "'background-color:#225588;color:#ffffff;'";
            } else {
                txt += "'background-color:#ffffff;color:#000000;'";
            }
            txt += ">&nbsp;" + $(this).text() + "<\/td><\/tr>";
        });

        txt += "<\/table><\/td><\/tr><\/table>";

        $("#empty").before(txt);
//        $("#categorySid").before("innerHTML", txt);

        $("#categoryMain").attr({
            onClick: function(a, b) {
		        if($("#" + a).css("display") == 'none') {
		            $("#" + b).css("background", "#FFFFFF");
		            $("#" + b).css("color", "#000000");
		            $("#" + a).css("display", "block");
		        } else {
		            $("#" + b).css("background", "#225588");
		            $("#" + b).css("color", "#FFFFFF");
		            $("#" + a).css("display", "none");            
		        }
            },
            
            onBlur: function() {
                $(this).css("background", "#FFFFFF");
                $(this).css("color", "#000000");                
            }
        });
    }

    function showLayer(a, b) {
        if($("#" + a).css("display") == 'none') {
            $("#" + b).css("background", "#FFFFFF");
            $("#" + b).css("color", "#000000");
            $("#" + a).css("display", "block");
        } else {
            $("#" + b).css("background", "#225588");
            $("#" + b).css("color", "#FFFFFF");
            $("#" + a).css("display", "none");            
        }
    }

    function over(obj) {
        $(obj).css("background", "#225588");
        $(obj).css("color", "#FFFFFF");  
    }
    
    function out(obj) {
        $(obj).css("background", "#FFFFFF");
        $(obj).css("color", "#000000");    
    }

    function change(obj, value) {
    	$("#categoryMain").text($(obj).text());
    	$("#categoryLayer").hide();

        $("#categorySid option").each(function () {
           if($(this).val() == value) {
               $(this).attr("selected", "true");
               $("#frmBbs").attr("action", "<c:url value='/bbs/list.do' />");
               $("#frmBbs").submit();
           } 
        });
    }

    $(document).ready(category);
    //]]>
    </script>
</head>
<body>
<%@ include file="/WEB-INF/jsp/include/top.jsp" %>
    <form:form id="frmBbs" method="post" action="../list.do" commandName="bbs" modelAttribute="bbs">
    <input type="hidden" id="bbsId" name="bbsId" value="${param.bbsId}"/>
    <div id="pw_content">
    <div id="pw_bbs" style="width: ${bbsType.bbsWidth}px;">
        <div id="pw_bbs_hader">${bbsType.bbsTopContent}</div>
        <div id="pw_bbs_body">
            <div id="pw_bbs_subject">
                <img src="<c:url value="/img/skin/${bbsType.bbsSkin}/title.gif"/>" class="pw_bsc" />
                <strong>${bbsType.bbsName}</strong> 
            </div>
            <div id="pw_bbs_comment">
            <c:if test="${not empty bbsType.bbsComment}">
                ${bbsType.bbsComment}
            </c:if>
            </div>    
            <c:choose>
            <c:when test="${bbsType.bbsType == 'A00101'}">
                <jsp:include page="./skin/${bbsType.bbsSkin}/list/list.jsp" />
            </c:when>
            <c:when test="${bbsType.bbsType == 'A00102'}">
                <jsp:include page="./skin/${bbsType.bbsSkin}/image/list.jsp" />
            </c:when>
            <c:when test="${bbsType.bbsType == 'A00103'}">
                <jsp:include page="./skin/${bbsType.bbsSkin}/guestbook/list.jsp" />
            </c:when>
            <c:when test="${bbsType.bbsType == 'A00104'}">
                <jsp:include page="./skin/${bbsType.bbsSkin}/forum/list.jsp" />
            </c:when>
            <c:when test="${bbsType.bbsType == 'A00105'}">
                <jsp:include page="./skin/${bbsType.bbsSkin}/wiki/dashboard.jsp" />
            </c:when>
            <c:otherwise>
                <jsp:include page="./skin/${bbsType.bbsSkin}/list/list.jsp" />
            </c:otherwise>
            </c:choose>    
        </div>
    </div>
    </div>
    </form:form>
<%@ include file="/WEB-INF/jsp/include/footer.jsp" %>
</body> 
</html>